﻿
/***********************************************/
//当前页面实例
var currentPage;
//控件集合实例
var controlsCollection;
//命名空间
var ModuleLsit;

$(document).ready(function () {
    var collection = [
        New(ASPxRFTextBox, ['txtModuleName', ['GroupA'], 'ModuleName']),
        New(ASPxRFTextBox, ['txtModuleCode', ['GroupA'], 'ModuleCode']),
         New(ASPxRFTextBox, ['txtModuleNameEn', ['GroupA'], 'ModuleNameEn'])
    ];
    controlsCollection = New(RapidForm, [collection]);

    //页面命名空间简写
    ModuleList = SGDemo.Permission.ModuleList;

    //声明页面信息
    var navigationInfo = { moduleValue: 'Permission', itemValue: 'ModuleItem', itemName: '模块明细' };
    currentPage = New(RFPage, [menuHeader, gvwList, ['btnEdit', 'btnView'], ['btnBulkEdit', 'btnDelete', 'btnAudit'], null, navigationInfo]);
    currentPage.firstLoad();
});

/***********************************************/
//删除
var doBulkDelete = function () {
    $.messager.confirm('确认提示', '确认删除吗?', function (result) {
        if (result) {
            //获取选择记录Keyids
            var keyids = gvwList.GetSelectedKeysOnPage().join('_');
            //调用删除方法
            ModuleList.BulkDelete(keyids, function (result) {
                if (result.value) {
                    gvwList.PerformCallback();
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除成功！',
                        showType: 'slide'
                    });

                } else {
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除失败！',
                        showType: 'slide'
                    });
                }
            });
        }
    });
}

//查找提交
function doSubmittedToSearch(s, e) {
    doListAll();
    $('#hfFilterCondition').val(controlsCollection.getQueryString('GroupA'));
    gvwList.PerformCallback();
}
//查找重置
var doResetToSearch = function (s, e) {
    controlsCollection.reset('GroupA');
}


/***********************************************/
//GridView选中全部或者取消选中全部
var doSelectOrUnselectAll = function (s, e) {
    gvwList.SelectAllRowsOnPage(s.GetChecked());
}
//GridView选择事件
function doSelectionChanged() {
    currentPage.selectionChanged();
}
//GridView双击行打开明细
function doRowDblClick(s, e) {
    currentPage.rowDblClick(s, e);
}
//明细
var doView = function () {
    currentPage.toView();
}
//新增
var doAdd = function () {
    currentPage.toAdd();
}
//编辑
var doEdit = function () {
    currentPage.toEdit();
}
//查找
var doSearch = function () {
    doDisplay('search');
    currentPage.toSearch();
}
//显示所有
var doListAll = function () {
    doDisplay('listall');
    currentPage.toListAll();
}
//刷新
var doRefresh = function () {
    $('#hfFilterCondition').val(' ')
    gvwList.PerformCallback();
}
//帮助
var doHelp = function () {
    window.open('../../../Help.aspx', 'Help'); // 打开一个标签页
}
//添加快捷方式
var doSetShortcut = function () {
    SGDemo.Permission.ModuleList.SaveFastAdd(function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式成功！',
                showType: 'slide'
            });

        } else {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式失败！',
                showType: 'slide'
            });
        }

    });
}